package com.dhj.jvmstudy.chapter07;

/**
 * String的垃圾回收
 * -Xms15m -Xmx15m -XX:+PrintStringTableStatistics -XX:+PrintGCDetails
 */
public class StringGCTest {

    public static void main(String[] args) {
        for(int i=0; i<100; i++){
            String.valueOf(i).intern();
        }

        /**

         无intern()：
         Number of entries       :      1775 =     42600 bytes, avg  24.000
         Number of literals      :      1775 =    158720 bytes, avg  89.420

         有intern()：
         Number of entries       :      1861 =     44664 bytes, avg  24.000
         Number of literals      :      1861 =    162640 bytes, avg  87.394

         */
    }

}
